<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function getrandom(min, max) {
            return Math.floor(Math.random() * (max - min + 1)) + min;
        }
        var random = getrandom(1, 10);
        alert("有奖竞猜,每个人只有三次机会");
        for (var i = 0; i < 4; i++) {
            var num = prompt("请输入数字进行竞猜");
            if (parseInt(random) == num) {
                alert("您猜对了！");
                break;
            } else if (parseInt(random) > num) {
                if (i == 2) {
                    alert("谢谢参与");
                    break;
                }
                alert("您猜小了！请继续");
                continue;
            } else if (parseInt(random) < num) {
                if (i == 2) {
                    alert("谢谢参与");
                    break;
                }
                alert("您猜大了！请继续");
                continue;
            }
        }
    </script>
</head>

<body>

</body>

</html>